<?php

namespace App\Traits\Relation\Inspection;

use App\Models\Inspection\Line;
use App\Models\Inspection\Node;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * 定义圈信息关联关系
 *
 * Trait CircleRelation
 * @package App\Traits\Relation\Inspection
 * Date: 22/04/2018
 * @author George
 */
trait CircleRelation
{
    /**
     * 获取圈所属线路信息
     *
     * Date: 22/04/2018
     * @author George
     * @return BelongsTo
     */
    public function line()
    {
        return $this->belongsTo(Line::class, 'line_id', 'id');
    }

    /**
     * 获取圈的节点信息
     *
     * Date: 22/04/2018
     * @author George
     * @return HasMany
     */
    public function nodes()
    {
        return $this->hasMany(Node::class, 'circle_id', 'id');
    }
}
